package com.cndym.serviceMap;

import com.cndym.exception.CndymException;
import com.cndym.exception.ErrCode;
import com.cndym.utils.ConfigUtils;
import com.cndym.utils.Utils;

import org.dom4j.Document;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;

import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

/**
 * 作者：邓玉明 时间：11-3-13 上午12:50  
 */

public class ServiceList {
    public static final String REGISTER_CODE = "0001";
    public static final String LOGIN_CODE = "0002";
    public static final String LOGIN_HISTORY_CODE = "0042";
    public static final String QUERY_USER_CODE = "0003";
    public static final String EDIT_MOBILE_CODE = "0004";
    public static final String EDIT_PASSWD_CODE = "0005";
    public static final String EDIT_CONTACT_CODE = "0006";
    public static final String EDIT_BANK_CODE = "0007";
    public static final String EDIT_EMAIL_CODE = "0017";
    public static final String EDIT_REAL_NAME_CODE = "0018";
    public static final String EDIT_TO_SEND_EMAIL = "0019";
    public static final String TOGETHER_CELEBRITY_QUERY = "0020";

    public static final String MOBILE_TEST = "0008";
    public static final String QUERY_MESSAGE_NUMBER = "0009";
    public static final String BONUS_QUERY = "0062";

    public static final String QUERY_PASSWORD_LEN = "0031";

    // email服务类型
    public static final String QUERY_EMAILSERVICE_TYPE = "0032";
    // 用户定制的email服务
    public static final String QUERY_EMAILSERVICE = "0033";
    public static final String ADD_EMAILSERVICE = "0034";
    public static final String UPDATE_EMAILSERVICE = "0035";
    public static final String ACCOUNT_LOG_COUNT = "0036";
    public static final String MOBLIE_TEST_ADD = "0038";
    public static final String REPLACE_PWD = "0039";
    public static final String MESSAGE_QUERY = "0040";
    public static final String MOBILE_TEST_SEND_TO_EMAIL = "0041";

    public static final String ACCOUNT_OPERATOR_CODE = "0010";
    public static final String FILL_SAVE_CODE = "0011";
    public static final String FILL_SAVE_CASH_COUPON = "0114";
    public static final String DRAW_SAVE_CODE = "0012";
    public static final String ACCOUNT_QUERY_CODE = "0013";
    public static final String ACCOUNT_LOG_QUERY_CODE = "0014";
    public static final String FILL_QUERY_CODE = "0015";
    public static final String DRAW_QUERY_CODE = "0016";

    public static final String ORDER = "0096";
    public static final String PROGRAMS_QUERY = "0051";
    public static final String ORDER_QUERY = "0052";
    public static final String TICKET_QUERY = "0053";
    public static final String ISSUE_QUERY = "0054";
    public static final String SUBGAME_QUERY = "0055";
    public static final String AUTOORDER_OUERY = "0056";
    public static final String PROGRAMS_VIEW = "0057";
    public static final String ISSUE_VIEW_QUERY = "0058";
    public static final String ISSUE_ITEM_QUERY = "0059";
    public static final String AUTO_ORDER_VIEW = "0060";
    public static final String ORDER_HM_VIEW = "0067";

    public static final String SMSVIP = "0030";
    public static final String QUERY_SMSVIP = "0037";

    public static final String CANCEL_ORDER = "0061";
    public static final String ORDER_ALL_QUERY = "0063";

    //合买认购
    public static final String TOGETHER_SUBSCRIBE = "0064";
    //合买撤单
    public static final String TOGETHER_CANCEL_PROGRAMS = "0065";
    //合买撤认购
    public static final String TOGETHER_CANCEL_RENGOU = "0066";
    //合买列表
    public static final String ORDER_HM_QUERY = "0068";
    //竞彩期次
    public static final String SUB_ISSUE_QUERY = "0069";
    //竞彩投注
    public static final String ORDER_FOR_SUB = "0070";
    //认购列表(统计每个用户)
    public static final String ORDER_SUBSCRIBE_QUERY = "0071";
    //用户的认购记录
    public static final String USER_ORDER_SUBSCRIBE_QUERY = "0072";

    public static final String QUERY_NEW_ISSUE = "0073";

    //合买定制
    public static final String TOGETHER_CUSTOMIZE = "0074";
    //被定制人列表
    public static final String TOGETHER_USER_QUERY = "0075";
    //已定制列表
    public static final String TOGETHER_CUSTOM_QUERY = "0076";
    //用户跟单统计
    public static final String TOGETHER_USER_ORDER_COUNT = "0077";
    //定制用户
    public static final String TOGETHER_CUSTOM_USER_QUERY = "0078";
    //被定制用户
    public static final String TOGETHER_CUSTOMIZED_USER_QUERY = "0079";
    //定制用户(用户中心)
    public static final String TOGETHER_CUSTOM_USER_LOTTERY_QUERY = "0080";
    //被定制用户(用户中心)
    public static final String TOGETHER_CUSTOMIZED_USER_LOTTERY_QUERY = "0081";
    //删除定制
    public static final String TOGETHER_CUSTOM_CANCEL = "0082";
    //邮箱找回密码
    public static final String FORGET_PASSWORD_BY_EMAIL = "0083";
    //自动跟单查询
    public static final String AUTO_SUBSCRIBE_QUERY = "0084";
    public static final String PROGRAMS_PACKAGE_QUERY = "0085";
    public static final String PROGRAMS_PACKAGE_DETAILS_QUERY = "0086";
    //手机号码验证
    public static final String USER_SMS_ADD = "0087";

    //根据手机号和用户名查询用户
    public static final String QUERY_USER_FOR_MOBILE_AND_NAME = "0088";

    //联盟登陆(如支付宝登陆)
    public static final String FOR_UNION_LOGIN = "0089";

    //竞彩赛果查询
    public static final String SUB_BONUS_QUERY = "0090";

    //竞彩投注场次查询
    public static final String SUB_ORDER_MATCH_QUERY = "0091";

    public static final String SUB_TICKET_MATCH_QUERY = "0092";

    //投注确认 查看方案明细
    public static final String SUB_TICKET_FOR_ORDER = "0093";
    //足彩方案详情 对阵详情
    public static final String SUB_GAME_FOR_ORDER = "0094";

    //保存方案
    public static final String SAVE_PROGRAMS = "0098";

    //保存方案(竟彩)
    public static final String SAVE_SUB_PROGRAMS = "0099";

    //后上传
    public static final String DELAY_TIME_UPLOAD = "0097";

    //竞彩单式上传
    public static final String SUB_UPLOAD = "0102";
    //保存方案查询
    public static final String SAVE_PROGRAMS_QUERY = "0103";
    //保存方案详情
    public static final String SAVE_PROGRAMS_DETAIL = "0104";

    public static final String SAVE_PROGRAMS_FOR_SUB_GAME = "0105";

    public static final String SAVE_PROGRAMS_FOR_SUB_MATCH = "0106";

    public static final String SAVE_PROGRAMS_FOR_SUB_UPLOAD = "0107";

    public static final String SAVE_PROGRAMS_FOR_UPLOAD = "0108";

    //竞彩单式上传场次
    public static final String ORDER_FOR_SUB_UPLOAD_MATCH = "0109";


    //QQ联合登录
    public static final String FOR_QQ_LOGIN = "0110";
    public static final String FOR_WB_LOGIN = "0111";
    public static final String FOR_KX_LOGIN = "0112";
    public static final String FOR_RR_LOGIN = "0113";



    //订单查询
    public static final String ORDER_QUERY_FOR_UNION = "1004";

    //返奖查询
    public static final String BONUS_QUERY_FOR_UNION = "1005";

    //期次查询
    public static final String ISSUE_QUERY_FOR_UNION = "1006";

    //开奖信息查询
    public static final String BONUSINFO_QUERY_FOR_UNION = "1007";

    //额度查询
    public static final String ACCOUNT_QUERY_FOR_UNION = "1008";

    //期次范姜查询
    public static final String BONUS_OF_ISSUE_QUERY_FOR_UNION = "1009";

    //联盟投注
    public static final String ORDER_FOR_UNION = "0050";


    //百威专栏
    //赛果查询
    public static final String SUB_BONUS_QUERY_FOR_BW = "2001";

    public static final String ORDER_FOR_UP_LOAD = "0095";
    
    //佣金用户查询
    public static final String COMMISS_QUERY_FOR="0121";
    
    //佣金订单查询 
    public static final String COMMISS_QUERY_ORDER_FOR="0122";
    
    //佣金关系查询 
    public static final String COMMISS_QUERY_MODEL_FOR="0124";
    
   //修改佣金用户类型 
    public static final String COMMISS_UPDATE_MODELSTATUS="0126";
    
    //修改佣金用户上级
    public static final String COMMISS_UPDATE_PLOGINNAME="0127";
    
    //查询返点详情
    public static final String COMMISS_QUERY_INFOLIST="0123";
    
    //修改下级返点
    public static final String COMMISS_UPDATE_INFOLIST="0125";

    //客户端接口新增
    public static final String DRAW_SAVE_FOR_CLIENT_API = "3001";

    private static Map<String, ServiceBean> map = new HashMap<String, ServiceBean>();

    static {
        forInstance();
    }

    public static void forInstance() {
        try {
            SAXReader xmlReader = new SAXReader();
            Document document = xmlReader.read(Utils.getClassPath() + ConfigUtils.getValue("SERVICE.CONFIG.PATH"));
            List list = document.selectNodes("/services/service");
            Iterator iterator = list.iterator();
            while (iterator.hasNext()) {
                Element element = (Element) iterator.next();
                ServiceBean lotteryBean = ServiceBean.toServiceBean(element);
                map.put(lotteryBean.getCmd(), lotteryBean);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static ServiceBean getServiceBean(String cmd) {
        if (map.containsKey(cmd)) {
            return map.get(cmd);
        }
        throw new CndymException(ErrCode.E2009);
    }

}
